
//var wsUri = "ws://localhost:48155/Admin/com/websockets/adminendpoint";
wsUri = "ws://" + document.location.host + "/Admin/adminendpoint";
var socket = new WebSocket(wsUri);
var output = document.getElementById("socketoutput");
output.innerHTML += wsUri + "<br/>";
function writeToScreen(message) {
    output.innerHTML += message + "<br/>";
}

websocket.onerror = function(evt) {
    onError(evt);
};
function onError(evt) {
    writeToScreen('<p style="color: red;">Error: </p>' + '<p>' + evt.data + '</p>' + wsUri);
}
websocket.onopen = function(evt) {
    onOpen(evt);
};
function onOpen() {
    writeToScreen('<p style="color: blue;">Connected to : ' + wsUri + '</p>');
}
websocket.onmessage = function(evt) {
    onMessage(evt);
};
function onMessage(evt) {
    console.log("Received: " + evt.data);
    //write sensor data to chart by js
//    var jsonarray = JSON.parse(evt.data);
//    writeToScreen(jsonarray);
}